package edu.upb.acs.jobsmaps.activity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import edu.upb.acs.jobsmaps.R;

public class MainGridViewAdapter extends BaseAdapter {
    private Context context;
    private final String[] options;

    public MainGridViewAdapter(Context context, String[] options) {
        this.context = context;
        this.options = options;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View gridView;

        if (convertView == null) {

            gridView = inflater.inflate(R.layout.grid_row, null);

            TextView textView = (TextView) gridView.findViewById(R.id.label);

            System.out.println("text view = " + options[position]);
            textView.setText(options[position]);

            ImageView flag = (ImageView) gridView.findViewById(R.id.flag);

            String mobile = options[position];

            if (mobile.equals("Job Search")) {
                flag.setImageResource(android.R.drawable.ic_menu_search);
            } else if (mobile.equals("Company Search")) {
                flag.setImageResource(android.R.drawable.ic_menu_search);
            } else if (mobile.equals("Admin")) {
                flag.setImageResource(android.R.drawable.ic_menu_manage);
            }if (mobile.equals("Speak")) {
				flag.setImageResource(android.R.drawable.ic_btn_speak_now);
			}
        } else {
            gridView = convertView;
        }

        return gridView;
    }

    @Override
    public int getCount() {
        return options.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

}